package cms.service.impl;

import cms.entity.User;
import cms.entity.UserExample;
import cms.mapper.UserMapper;
//import cms.mapper.UserMapperImpl;
import cms.service.loginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class loginServiceImpl implements loginService {

    @Autowired
    private UserMapper userMapper;


    public boolean login(User user) {

        UserExample example=new UserExample();
        UserExample.Criteria criteria=example.createCriteria();
        criteria.andUsernameEqualTo(user.getUsername());

        System.out.println("Access-------------------------Impl1");
        List<User> list=userMapper.selectByExample(example);

        User u=list.get(0);

        System.out.println("Access-------------------------Impl2");
       /* for (User temp:list
             ) {
            System.out.println(temp.getUsername()+"---list--->"+temp.getPassword());
        }

        User u=new User();
*/

       System.out.println(u.getUsername()+"---------"+u.getPassword());
        System.out.println(u.getPassword().equals(user.getPassword())+"---------------");
        if(u.getPassword().equals(user.getPassword())){
            return true;
        }else{
            return false;
        }

    }
}
